// import { key } from './test'
import One from './onedemo'

console.log(1213)

function greeter(person: string) {
  return 'Hello, ' + person
}

const isLoading: boolean = false
const num: number = 12
const book: string = '深入浅出 js'
// let book2: void = null

const sym1 = Symbol('key1')
console.log('sym1: ', sym1)

let x: [string, number]
x = ['11', 33]
const user = 'Jane User'

enum Dire {
  Up = 'up',
  Down = 'do',
  Left = 'left',
  Right = 'right',
}

enum Dire1 {
  Up,
  Down,
  Left,
  Right,
}

const a = 0

console.log('Dire: ', a === Dire1.Up)

interface User {
  name: string
  age?: number
  readonly isMale: boolean
  say: Say
  phone: Phone
}

interface Phone {
  [name: string]: string
}

interface VipUser extends User {}

interface Say {
  (word: string): string
}

const getUserName = (user: User) => user.name
// abstract
class Animal {
  name: string
  private age: number
  constructor(name: string, age: number) {
    this.name = name
    this.age = age
  }

  say() {
    console.log('Animal.say')
  }
}

let aa = new Animal('aha', 20)

// class Dog extends Animal {
//   constructor(name: string) {
//     super(name)
//   }
//   say() {
//     console.log('狗狗')
//   }
// }

// interface Do {
//   name: string
//   say: () => void
// }
// // let a12: Do = new Animal('小狗')
// // console.log(a12)

// let d1: Do = new Dog('二郎神')
// console.log('d1: ', d1)

// // a12.say()
// d1.say()
/**
 * api返回提示函数
 * @param code 状态码,数字或者字符串
 * @param msg {string} 提示消息字符串
 * @param type 类型,a或者b
 *
 * [还不懂？点这里吧](https://www.google.com)
 *
 * ```js
 * // 例子
 * resMsg(0,"注册成功",'a')
 * ```
 */

function resMsg(
  code: number | string,
  type: 'a' | 'b',
  msg: string = '默认提示'
): string {
  return `${code}--${msg}--${type}`
}

let rr: string = resMsg(9, 'a')
console.log('rr: ', rr)

resMsg(1, 'a', 'asdsa')

/**
 *
 * @param a
 * @param age
 * @param man
 * @param job
 */
function testfun(
  a: string,
  age: number,
  man: boolean = false,
  job: 'web' | 'php' | 'nodejs' | 'python' | 'golang'
): object {
  return {}
}

interface Person {
  /**姓名 */
  name: string
  /**年龄 */
  age: number
  /**职业 */
  job: string
}

type dataArray = Person[]

function haha() {
  let mm = [
    {
      name: '张三',
      age: 20,
      job: 'web',
    },
    {
      name: '张三',
      age: 20,
      job: 'web',
    },
    {
      name: '张三',
      age: 20,
      job: 'web',
    },
  ]
  return new Promise<dataArray>((resolve, reject) => {
    resolve(mm)
  })
}

haha().then((res) => {
  res[0].name
})

// haha(mm)

let add: (x: number, y: number) => number = function (
  x: number,
  y: number
): number {
  return x + y
}

let rrrr: number = add(3, 5)
console.log('rrrr: ', rrrr)
let m: []

function buildname(firstname: string = 'ming', lastname?: string) {
  console.log(firstname + lastname)
}

buildname(undefined, '人')

let st: string = '防辐射的'

st.length
let uPop = {
  /**
   * 消息弹窗toast
   * @param text 显示的文案
   * @param icon 否是显示图标
   * @param time 展示时间
   */
  msg(text: string, icon: boolean, time: number) {
    return '123'
  },
}

uPop.msg('12312312', true, 342)
uPop.msg('asd', true, 543)
// uPop.msg()

console.log('-------------')
console.log(One)
// git cz
// git cz
